<template>
	<view class="bg">
		<view class="flex-row justify-center">
			<image src="../../static/images/newgifttitle.png" class="top" mode=""></image>
		</view>

		<view class="list">
			<view class="title">
				新人专享优惠券全家桶
			</view>
			<my-coupon class="sm" :type="i.coupon_type.type_class" :amount="i.amount" :threshold="i.threshold" :expire="`领取后${i.valid_day}天内有效`" btn="新人专享" v-for="i in coupon" :key="i.id"></my-coupon>
		</view>

		<view class="bigbtn" :class="{ over: over }" @click="getGift">
			{{ over ? '已领取' : '立即领取' }}
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				over: false,
				coupon: []
			};
		},
		onLoad() {
			if (this.$store.state.userinfo && this.$store.state.userinfo.new_reg_gift!=0) {
				this.over = true
			}
			this.getCoupon()
		},
		methods: {
			getGift() {
				if (!this.over) {
					this.$u.get('/reward/register').then(res => {
						this.$msg(res.data.msg)
						this.over = true
						this.$u.api.getUserinfo()
					})
				}
			},
			getCoupon() {
				this.$u.get('/reward/reg/list').then(res => {
					this.coupon = res.data.result.coupon
				})
			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #F9482B;
	}
	.bg {
		width: 750rpx;
		height: 2028rpx;
		background: url(../../static/images/newgift.png);
		background-size: 100% auto;
	}

	.top {
		margin-top: 100rpx;
		width: 560rpx;
		height: 240rpx;
	}

	.list {
		margin: 520rpx auto 0 auto;
		width: 670rpx;
		height: 1280rpx;
		background: rgba(255, 247, 230, 1);
		border-radius: 20rpx;
		border: 8rpx solid rgba(253, 224, 122, 1);

		.title {
			width: 357rpx;
			height: 50rpx;
			margin: 32rpx auto;
			font-size: 36rpx;
			font-family: AlibabaPuHuiTi-Heavy, AlibabaPuHuiTi;
			font-weight: 800;
			color: rgba(255, 139, 86, 1);
			line-height: 50rpx;
			position: relative;
			&::before {
				content: '';
				width: 16rpx;
				height: 16rpx;
				background: #FF8B56;
				position: absolute;
				left: -40rpx;
				top: 50%;
				transform: translate(0, -50%) rotate(45deg);
			}
			&::after {
				content: '';
				width: 16rpx;
				height: 16rpx;
				background: #FF8B56;
				position: absolute;
				right: -40rpx;
				top: 50%;
				transform: translate(-50%, -50%) rotate(45deg);
			}
		}
	}

	.sm {
		transform: scale(0.85);
		margin-top: 8rpx !important;
	}

	/deep/ .coupon {
		.left-dot {
			background: #FFF7E6 !important;
		}
	}

	.bigbtn {
		width: 670rpx;
		height: 102rpx;
		margin: 50rpx auto;
		background: linear-gradient(180deg, rgba(253, 234, 83, 1) 0%, rgba(250, 209, 41, 1) 100%);
		border-radius: 20rpx;
		font-size: 40rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: rgba(249, 73, 41, 1);
		display: flex;
		justify-content: center;
		align-items: center;

		&.over {
			background: #E9ECEF;
			color: rgba(0, 0, 0, 0.5);
		}
	}
</style>
